# Maintainer: Jenneron <jenneron@protonmail.com>
pkgname=linux-postmarketos-mediatek-mt81xx
pkgver=6.12.0_rc1_git20241108
pkgrel=1
pkgdesc="Mediatek MT8186/8192/8195 kernel package"
arch="aarch64"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip
	!check
	!tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
	"
makedepends="
	bash
	bison
	findutils
	flex
	openssl-dev
	perl
	gmp-dev
	mpc1-dev
	mpfr-dev
	xz
	postmarketos-installkernel
"

# Source
_flavor="${pkgname#linux-}"
_config="config-$_flavor.$arch"
_repository="chromeos-kernel"
_carch="arm64"
_flavor="${pkgname#linux-}"
_commit="a2edb886602363f24c18f47c6ee10999abf9a79f"
source="
	$pkgname-$_commit.tar.gz::https://gitlab.collabora.com/google/$_repository/-/archive/$_commit/chromeos-kernel-$_commit.tar.gz
	0001-arm64-dts-mediatek-Add-dts-for-hayato-rev5-sku0.patch
	remove-audio-routing.patch
	$_config
"
builddir="$srcdir/$_repository-$_commit"

prepare() {
	default_prepare
	cp "$srcdir/$_config" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot

	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}


sha512sums="
7af3164cf718565120bba76b70e62ba24b10d0984b799a5778fb7cacc61c1b88036068d27021b19f9eca21c0ea8714a6d0274dfb4b3c0969f59359e354de0f29  linux-postmarketos-mediatek-mt81xx-a2edb886602363f24c18f47c6ee10999abf9a79f.tar.gz
bf39ed6646a869a7a99dc7f0ccc7bbaca0c50776e87848cb1a9e55bef317a73c08549a9acb8cce5c394ab3bf90667e4d1cf8a3671bb9de15d2a470d5e8be0261  0001-arm64-dts-mediatek-Add-dts-for-hayato-rev5-sku0.patch
f10464bf131ba44686a36a35aaf16492915413893d1b3faa43959d5f853b5ed66419f835565836a17480cd3458de0943cee72e700713e00125c8ecd184f3b677  remove-audio-routing.patch
8e567dae43e1fc94cffed560aed334d06cc49c668856c07dff1442a39205a04b6e671dce8401868c558fac9bea4d08ec42908d643d17856479680e49348729e8  config-postmarketos-mediatek-mt81xx.aarch64
"
